/**
 * Created by haocongshun on 2016/10/5.
 */
var contextPath = "";
$(function () {
    contextPath  = getContextPath();
    $("#sub").click(function () {
        if(checkNull()){
           var url = contextPath+"/login/adminLogin.press";
            var data = {};
            data.username = $("#username").val();
            data.password = $("#password").val();
            $.ajaxSetup({
                async : false
            });
            $.post(url,data,function (result) {
                if(result.Msg){
                    $("#adminLogin").submit();
                }else {
                    alert("用户名或密码错误！");
                }
            },"json");
        }
    });
});
function checkNull() {
    if($("#username").val()==""||$("#username").val()==null){
        alert("用户名不能为空！");
        return false;
    }
    if($("#password").val()==""||$("#password").val()==null){
        alert("密码不能为空！");
        return false;
    }
    return true;
}
